import path from 'path'
import multer from 'multer'
import { response, request } from 'express'

const storage = multer.diskStorage({
    destination: (req, file, cb) => {
        // 定义在什么目录接收
        cb(null, 'static/uploads/')
    },
    filename: (req, file, cb) => {
        const extname = path.extname(file.originalname)
        let date = new Date()
        let year = date.getFullYear()
        let month = date.getMonth() + 1;
        let day = date.getDate()
        // 定义文件目录名
        cb(null, `${year}_${month}_${day}_${Date.now() + extname}`)
    }
});
const upload = multer({ storage })

export { upload } 